package com.ruoyi.web.controller.memberCoupon;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CouponOverview;
import com.ruoyi.system.service.ICouponOverviewService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 卡券概览 Controller
 *
 * @author ruoyi
 * @date 2025-05-20
 */
@Api(tags="卡券概览")
@RestController
@RequestMapping("/system/couponOverview")
public class CouponOverviewController extends BaseController
{
    @Autowired
    private ICouponOverviewService couponOverviewService;

    /**
     * 查询卡券概览列表
     */
    @ApiOperation("查询卡券概览列表")
    @PreAuthorize("@ss.hasPermi('system:overview:list')")
    @GetMapping("/list")
    public TableDataInfo list( CouponOverview couponOverview)
    {
        startPage();
        List<CouponOverview> list = couponOverviewService.selectCouponOverviewList(couponOverview);
        return getDataTable(list);
    }

    /**
     * 导出卡券概览列表
     */
    @ApiOperation("导出卡券概览列表")
    @PreAuthorize("@ss.hasPermi('system:overview:export')")
    @Log(title = "卡券概览", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response,  CouponOverview couponOverview)
    {
        List<CouponOverview> list = couponOverviewService.selectCouponOverviewList(couponOverview);
        ExcelUtil<CouponOverview> util = new ExcelUtil<CouponOverview>(CouponOverview.class);
        util.exportExcel(response, list, "卡券概览数据");
    }

    /**
     * 通过id获取卡券概览详细信息
     */
    @ApiOperation("通过id获取卡券概览详细信息")
    @PreAuthorize("@ss.hasPermi('system:overview:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(couponOverviewService.selectCouponOverviewById(id));
    }

    /**
     * 新增卡券概览信息
     */
    @ApiOperation("新增卡券概览信息")
    @PreAuthorize("@ss.hasPermi('system:overview:add')")
    @Log(title = "卡券概览", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CouponOverview couponOverview)
    {
        return toAjax(couponOverviewService.insertCouponOverview(couponOverview));
    }

    /**
     * 修改卡券概览
     */
    @ApiOperation("修改卡券概览信息")
    @PreAuthorize("@ss.hasPermi('system:overview:edit')")
    @Log(title = "卡券概览", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CouponOverview couponOverview)
    {
        return toAjax(couponOverviewService.updateCouponOverview(couponOverview));
    }

    /**
     * 通过id批量删除卡券概览信息
     */
    @ApiOperation("通过id批量删除卡券概览信息")
    @PreAuthorize("@ss.hasPermi('system:overview:remove')")
    @Log(title = "卡券概览", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(couponOverviewService.deleteCouponOverviewByIds(ids));
    }
}
